<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('cd_organization')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <cd-organization-modal ref="modalForm" @ok="modalFormOk"></cd-organization-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import CdOrganizationModal from './modules/CdOrganizationModal'

  export default {
    name: 'CdOrganizationList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      CdOrganizationModal
    },
    data () {
      return {
        description: 'cd_organization管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'机构ID',
            align:"center",
            dataIndex: 'orgId'
          },
          {
            title:'机构名称',
            align:"center",
            dataIndex: 'orgName'
          },
          {
            title:'机构英文名称',
            align:"center",
            dataIndex: 'enOrgName'
          },
          {
            title:'localOrgName',
            align:"center",
            dataIndex: 'localOrgName'
          },
          {
            title:'机构简称',
            align:"center",
            dataIndex: 'orgShortName'
          },
          {
            title:'corporateRepresentative',
            align:"center",
            dataIndex: 'corporateRepresentative'
          },
          {
            title:'orgDesc',
            align:"center",
            dataIndex: 'orgDesc'
          },
          {
            title:'机构代码',
            align:"center",
            dataIndex: 'orgCode'
          },
          {
            title:'单位职能',
            align:"center",
            dataIndex: 'orgType'
          },
          {
            title:'机构级别',
            align:"center",
            dataIndex: 'orgLevel'
          },
          {
            title:'行政区名称',
            align:"center",
            dataIndex: 'canton'
          },
          {
            title:'行政区代码',
            align:"center",
            dataIndex: 'cantonCode'
          },
          {
            title:'地址',
            align:"center",
            dataIndex: 'address'
          },
          {
            title:'homeUrl',
            align:"center",
            dataIndex: 'homeUrl'
          },
          {
            title:'authorizedOrgIf',
            align:"center",
            dataIndex: 'authorizedOrgIf'
          },
          {
            title:'是否生产单位',
            align:"center",
            dataIndex: 'forbidIf'
          },
          {
            title:'isEmptyOrg',
            align:"center",
            dataIndex: 'isEmptyOrg'
          },
          {
            title:'启用或停用标识',
            align:"center",
            dataIndex: 'currentState'
          },
          {
            title:'remarks',
            align:"center",
            dataIndex: 'remarks'
          },
          {
            title:'创建人',
            align:"center",
            dataIndex: 'createDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'创建人ID',
            align:"center",
            dataIndex: 'createUserId'
          },
          {
            title:'创建人应用ID',
            align:"center",
            dataIndex: 'createAppId'
          },
          {
            title:'更新日期',
            align:"center",
            dataIndex: 'updateDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'更新人ID',
            align:"center",
            dataIndex: 'updateUserId'
          },
          {
            title:'审核日期',
            align:"center",
            dataIndex: 'checkDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'审核人ID',
            align:"center",
            dataIndex: 'checkUserId'
          },
          {
            title:'mdmCode',
            align:"center",
            dataIndex: 'mdmCode'
          },
          {
            title:'cantonDesc',
            align:"center",
            dataIndex: 'cantonDesc'
          },
          {
            title:'companyId',
            align:"center",
            dataIndex: 'companyId'
          },
          {
            title:'customerDivision',
            align:"center",
            dataIndex: 'customerDivision'
          },
          {
            title:'customerGroup',
            align:"center",
            dataIndex: 'customerGroup'
          },
          {
            title:'customerTelephone',
            align:"center",
            dataIndex: 'customerTelephone'
          },
          {
            title:'reportingStandard',
            align:"center",
            dataIndex: 'reportingStandard'
          },
          {
            title:'reportingTime',
            align:"center",
            dataIndex: 'reportingTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'attachmentJournalId',
            align:"center",
            dataIndex: 'attachmentJournalId'
          },
          {
            title:'mustVerifyFlag',
            align:"center",
            dataIndex: 'mustVerifyFlag'
          },
          {
            title:'oilField',
            align:"center",
            dataIndex: 'oilField'
          },
          {
            title:'bsflag',
            align:"center",
            dataIndex: 'bsflag'
          },
          {
            title:'sendIndicate',
            align:"center",
            dataIndex: 'sendIndicate'
          },
          {
            title:'createOrgId',
            align:"center",
            dataIndex: 'createOrgId'
          },
          {
            title:'updateOrgId',
            align:"center",
            dataIndex: 'updateOrgId'
          },
          {
            title:'orgFunction',
            align:"center",
            dataIndex: 'orgFunction'
          },
          {
            title:'orgAdmLevel',
            align:"center",
            dataIndex: 'orgAdmLevel'
          },
          {
            title:'source',
            align:"center",
            dataIndex: 'source'
          },
          {
            title:'删除标志，1-删除，0或空未删除',
            align:"center",
            dataIndex: 'deleFlag'
          },
          {
            title:'父级组织机构ID',
            align:"center",
            dataIndex: 'orgParentId'
          },
          {
            title:'审批意见',
            align:"center",
            dataIndex: 'checkOpinion'
          },
          {
            title:'注册审批状态',
            align:"center",
            dataIndex: 'checkState'
          },
          {
            title:'排序号',
            align:"center",
            dataIndex: 'sorder'
          },
          {
            title:'业务编码',
            align:"center",
            dataIndex: 'businessCode'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/cdOrganization/cdOrganization/list",
          delete: "/cdOrganization/cdOrganization/delete",
          deleteBatch: "/cdOrganization/cdOrganization/deleteBatch",
          exportXlsUrl: "/cdOrganization/cdOrganization/exportXls",
          importExcelUrl: "cdOrganization/cdOrganization/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'orgId',text:'机构ID',dictCode:''})
        fieldList.push({type:'Text',value:'orgName',text:'机构名称',dictCode:''})
        fieldList.push({type:'string',value:'enOrgName',text:'机构英文名称',dictCode:''})
        fieldList.push({type:'string',value:'localOrgName',text:'localOrgName',dictCode:''})
        fieldList.push({type:'string',value:'orgShortName',text:'机构简称',dictCode:''})
        fieldList.push({type:'string',value:'corporateRepresentative',text:'corporateRepresentative',dictCode:''})
        fieldList.push({type:'Text',value:'orgDesc',text:'orgDesc',dictCode:''})
        fieldList.push({type:'string',value:'orgCode',text:'机构代码',dictCode:''})
        fieldList.push({type:'string',value:'orgType',text:'单位职能',dictCode:''})
        fieldList.push({type:'string',value:'orgLevel',text:'机构级别',dictCode:''})
        fieldList.push({type:'string',value:'canton',text:'行政区名称',dictCode:''})
        fieldList.push({type:'string',value:'cantonCode',text:'行政区代码',dictCode:''})
        fieldList.push({type:'Text',value:'address',text:'地址',dictCode:''})
        fieldList.push({type:'string',value:'homeUrl',text:'homeUrl',dictCode:''})
        fieldList.push({type:'string',value:'authorizedOrgIf',text:'authorizedOrgIf',dictCode:''})
        fieldList.push({type:'string',value:'forbidIf',text:'是否生产单位',dictCode:''})
        fieldList.push({type:'string',value:'isEmptyOrg',text:'isEmptyOrg',dictCode:''})
        fieldList.push({type:'string',value:'currentState',text:'启用或停用标识',dictCode:''})
        fieldList.push({type:'Text',value:'remarks',text:'remarks',dictCode:''})
        fieldList.push({type:'date',value:'createDate',text:'创建人'})
        fieldList.push({type:'string',value:'createUserId',text:'创建人ID',dictCode:''})
        fieldList.push({type:'string',value:'createAppId',text:'创建人应用ID',dictCode:''})
        fieldList.push({type:'date',value:'updateDate',text:'更新日期'})
        fieldList.push({type:'string',value:'updateUserId',text:'更新人ID',dictCode:''})
        fieldList.push({type:'date',value:'checkDate',text:'审核日期'})
        fieldList.push({type:'string',value:'checkUserId',text:'审核人ID',dictCode:''})
        fieldList.push({type:'string',value:'mdmCode',text:'mdmCode',dictCode:''})
        fieldList.push({type:'Text',value:'cantonDesc',text:'cantonDesc',dictCode:''})
        fieldList.push({type:'string',value:'companyId',text:'companyId',dictCode:''})
        fieldList.push({type:'string',value:'customerDivision',text:'customerDivision',dictCode:''})
        fieldList.push({type:'string',value:'customerGroup',text:'customerGroup',dictCode:''})
        fieldList.push({type:'string',value:'customerTelephone',text:'customerTelephone',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'reportingStandard',text:'reportingStandard',dictCode:''})
        fieldList.push({type:'date',value:'reportingTime',text:'reportingTime'})
        fieldList.push({type:'string',value:'attachmentJournalId',text:'attachmentJournalId',dictCode:''})
        fieldList.push({type:'string',value:'mustVerifyFlag',text:'mustVerifyFlag',dictCode:''})
        fieldList.push({type:'string',value:'oilField',text:'oilField',dictCode:''})
        fieldList.push({type:'string',value:'bsflag',text:'bsflag',dictCode:''})
        fieldList.push({type:'string',value:'sendIndicate',text:'sendIndicate',dictCode:''})
        fieldList.push({type:'string',value:'createOrgId',text:'createOrgId',dictCode:''})
        fieldList.push({type:'string',value:'updateOrgId',text:'updateOrgId',dictCode:''})
        fieldList.push({type:'string',value:'orgFunction',text:'orgFunction',dictCode:''})
        fieldList.push({type:'string',value:'orgAdmLevel',text:'orgAdmLevel',dictCode:''})
        fieldList.push({type:'string',value:'source',text:'source',dictCode:''})
        fieldList.push({type:'string',value:'deleFlag',text:'删除标志，1-删除，0或空未删除',dictCode:''})
        fieldList.push({type:'string',value:'orgParentId',text:'父级组织机构ID',dictCode:''})
        fieldList.push({type:'Text',value:'checkOpinion',text:'审批意见',dictCode:''})
        fieldList.push({type:'string',value:'checkState',text:'注册审批状态',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'sorder',text:'排序号',dictCode:''})
        fieldList.push({type:'string',value:'businessCode',text:'业务编码',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>